home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 September / maximum-cd-2000-09.iso / Vampire the Masquerade / vampire_demo.exe / Codex.nob / FeederRatClassWander.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  3.1 KB  |  93 lines

  1. public class FeederRatClassWander extends Codex {
  2.    private static final int TIMER_ID_WANDER = 0;
  3.    private static final int THINK_TIME = 2;
  4.    private static final int RESTART_BUFFER = 10;
  5.    private CodexActor _wanderThing = new CodexActor(((Codex)this).GetClassThing());
  6.    private float _minSearch = 64.0F;
  7.    private float _maxSearch = 320.0F;
  8.    private float _minDelay = 2.0F;
  9.    private float _maxDelay = 10.0F;
  10.    private float _speed = 210.0F;
  11.    private float _stepHeight = 16.0F;
  12.    private int _editorPlaced = 1;
  13.    private float[] pos = new float[3];
  14.    public static String[] _params = new String[]{"Min search radius;64", "Max search radius;320", "Min delay;2", "Max delay; 10", "Speed;210", "Step height to try; 16", "Placed in Editor (LEAVE AT 1 IF YOU SEE THIS);1"};
  15.  
  16.    public void created(int guid) {
  17.       this.SendThing();
  18.    }
  19.  
  20.    public void clicked(int guid, int clickerGuid, int captureID) {
  21.       CodexThing ratThing = new CodexThing(guid);
  22.       if (ratThing != null) {
  23.          CodexPlayer player = new CodexPlayer(clickerGuid);
  24.          int ratItemGuid = ratThing.SpawnThing("vitaeRat");
  25.          ((CodexActor)player).AddToActorInventory(ratItemGuid);
  26.          ratThing.Remove();
  27.       }
  28.  
  29.    }
  30.  
  31.    public void beginscene(int clientGuid, int captureID) {
  32.       this.SendThing();
  33.    }
  34.  
  35.    public void arrived(int thingGuid, int frameNum, int captureID) {
  36.       ((Codex)this).SetTimer((float)((double)this._minDelay + Math.random() * (double)(this._maxDelay - this._minDelay)), 0);
  37.    }
  38.  
  39.    public void SendThing() {
  40.       boolean bSuccess = false;
  41.       this.pos = this._wanderThing.GetPosition();
  42.       this.pos[0] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
  43.       this.pos[1] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
  44.  
  45.       while(!bSuccess) {
  46.          if (this._wanderThing.SendActorToPos(this.pos, this._speed)) {
  47.             bSuccess = true;
  48.             ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
  49.          } else {
  50.             this.pos[2] += this._stepHeight;
  51.             if (!this._wanderThing.SendActorToPos(this.pos, this._speed)) {
  52.                ((Codex)this).SetTimer(2.0F, 0);
  53.                break;
  54.             }
  55.  
  56.             bSuccess = true;
  57.             ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
  58.          }
  59.       }
  60.  
  61.    }
  62.  
  63.    public FeederRatClassWander(float minSearch, float maxSearch, float minDelay, float maxDelay, float speed, float stepHeight, int editorPlaced) {
  64.       this._editorPlaced = editorPlaced;
  65.       if (this._editorPlaced != 0) {
  66.          this._minSearch = minSearch;
  67.          this._maxSearch = maxSearch;
  68.          this._minDelay = minDelay;
  69.          this._maxDelay = maxDelay;
  70.          this._speed = speed;
  71.          this._stepHeight = stepHeight;
  72.       } else {
  73.          this._minSearch = 64.0F;
  74.          this._maxSearch = 320.0F;
  75.          this._minDelay = 2.0F;
  76.          this._maxDelay = 10.0F;
  77.          this._speed = 210.0F;
  78.          this._stepHeight = 16.0F;
  79.       }
  80.  
  81.    }
  82.  
  83.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  84.       switch (timerID) {
  85.          case 0:
  86.             ((Codex)this).KillAllTimers();
  87.             this._wanderThing.Stop();
  88.             this.SendThing();
  89.          default:
  90.       }
  91.    }
  92. }
  93.